package com.puhui.lib.utils.encrypt;

import android.text.TextUtils;

import org.apache.commons.codec.digest.Sha2Crypt;

/**
 * SHA加密
 */
public class SHAEncryptUtil {

    public static String encrypt(String source, String salt) {
        if (TextUtils.isEmpty(source)) {
            return source;
        }
        return Sha2Crypt.sha256Crypt(source.getBytes(), salt);
    }

    public static String encrypt(String source) {
        if (TextUtils.isEmpty(source)) {
            return source;
        }
        return Sha2Crypt.sha256Crypt(source.getBytes());
    }

    public static String encryptBy512(String source) {
        if (TextUtils.isEmpty(source)) {
            return source;
        }
        return Sha2Crypt.sha512Crypt(source.getBytes());
    }

    public static String encryptBy512(String source, String salt) {
        if (TextUtils.isEmpty(source)) {
            return source;
        }
        return Sha2Crypt.sha512Crypt(source.getBytes(), salt);
    }
}
